<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'exchange-index', //页面标示
    'pagename' => '积分兑换列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content" class="main-section">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
        <div class="row">
			<!-- table 11 -->
			<div class="col-lg-12"> 
				<section class="panel">
               <!---->
                <div class="panel-body">
                  <div class="row text-small">
                    <div class="col-sm-8">
                    	<a class="btn btn-default" href="<?php echo U('exchange/index');?>">返回列表</a>
                        <div class="btn-group" style="margin-left:20px">
                           <a class="btn btn-default" href="<?php echo U('exchange/tlist',array('all'=>1));?>">全部</a>
                           <a class="btn btn-default" href="<?php echo U('exchange/tlist',array('id'=>$id,'status'=>2));?>">已兑换</a>
                           <a class="btn btn-default" href="<?php echo U('exchange/tlist',array('id'=>$id,'status'=>1));?>">未兑换</a>
                        </div>
                    </div>
                    <div class="col-sm-4">
                      <form action="<?php echo U(ACTION_NAME.'/tlist');?>" method="get" name="form1" target="_self">
                        <div class="input-group">
                        	<input name="id" type="hidden" value="<?php echo $id;?>">
                          <input type="text" name="q" class="input-sm form-control" placeholder="请输入兑换码..." />
                          <input name="g" type="hidden" value="<?php echo GROUP_NAME;?>" />
                          <input name="c" type="hidden" value="<?php echo ACTION_NAME;?>" />
                          <input name="m" type="hidden" value="<?php echo MODEL_NAME;?>" />
                          <span class="input-group-btn">
                          <button class="btn btn-sm btn-white" type="submit">搜索</button>
                          </span> </div>
                      </form>
                    </div>
                  </div>
                </div>
                <!---->
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							 <thead>
                                <tr>
                                 <th align="center">ID</th>
                                <th align="center">UID</th>
                                <th align="center">姓名</th>
                                <th align="center">电话</th>
                                <th align="center">兑换数量</th> 
                                <th align="center">兑换码</th>
                                <th align="center">兑换时间</th>
                                <th align="center">使用时间</th>
                                <th align="center">状态</th>
                                <th align="center">操作</th>
                                </tr>
                              </thead>
                              <tbody>
                              <?php
                              if ($rs){
                                  foreach($rs as $val){
                              ?>
						<td><?php echo $val['id'];?></td>
                        <td><?php echo $val['uid'];?></td>
                        <td><a href="<?php echo U('member/index',array('uid'=>$val['uid']));?>"><?php echo $val['nickname'];?></a></td>
                        <td><?php echo $val['phone'];?></td>
                        <td><?php echo $val['counts'];?></td>
                        <td><?php echo $val['code'];?></td>
                        <td><?php echo ($val['infotime']?outTime($val['infotime']):'');?></td>
                        <td><?php echo ($val['use_time']?outTime($val['use_time']):'');?></td>
                        <td id="status_<?php echo $val['id'];?>"><?php echo $status[$val['status']];?></td>
                                  <td>
                                  <div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                    <ul class="dropdown-menu">
                                    	<li><a href="javascript:;" rel="<?php echo $val['id'];?>" class="deal">处理</a></li>
                                    </ul> 
								</div>
                                  </td>
                                </tr>
                                <?php
                                  }
                              }else{
                                ?>
                               <tr>
                                  <td colspan="20" align="center">暂无数据</td>
                                </tr>
                              <?php
                              }
                              ?>
                              </tbody>
						</table> 
					</div> 
 					<footer class="panel-footer"> 
						<div class="row"> 
							<div class="col-sm-12 text-right text-center-sm"> 
									<?php echo page($total,$p,'',20,'p');?>
							</div> 
						</div> 
					</footer>
				</section> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
	$('.deal').click(function(){
		var id=$(this).attr('rel');
	  //调用smoothConfirm 插件
	  $(this).smoothConfirm("请选择处理方式：", {
		  okVal: "<?php echo $status[1];?>",
		  cancelVal: '关闭',
		  //点击确认返回callback
		  ok: function() {
			  $.getJSON('<?php echo U('exchange/deal');?>',{"do":"ok",id:id},function(res){
				if (res.status==1){
					$("#status_"+id).html('<?php echo $status[1];?>');	  
				}else{
					Msg.error(res.info);	  
				}
			  });
		  },
		  //点击取消返回callback
		  cancel: function() {
				return ;
		  }
	  });
	  $("body").click();
	  return false;
	})	
})
</script>
<?php
include getTpl('footer', 'public');
?>